<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>基本信息页面</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="/css/font.css">
        <link rel="stylesheet" href="/css/xadmin.css">
        <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
        <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/js/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
        <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
        <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->

    </head>
    <body>
    <div class="x-body layui-anim layui-anim-up">

        <fieldset class="layui-elem-field">
            <legend>安装软件</legend>
            <div class="layui-field-box">
                <table class="layui-table">
                    <tbody id="data-body">

                    </tbody>
                </table>
            </div>
        </fieldset>
    </div>
    </body>
    <script>
        // 获取传递的id
        let id = "[[${#request.getParameter('id')}]]";

        $(function () {
            $.ajax({
                type:"post",
                url:"/scan/data/detail",
                data: {id: id},
                dataType:"json",
                success:function (data) {
                    console.log(data);
                    if(data.code === 200){
                        //清空数据
                        $("#data-body").empty();
                        // 获取数据
                        let strData = data.data.data;
                        // 转换成标准的json格式
                        strData = strData.replace(/'/g, "\"");
                        let jsonData = JSON.parse(strData);
                        let index = 1;
                        // 遍历数据的数组,生成对应的行
                        $(jsonData).each(function () {
                            // 创建数据行的dom对象
                            let tr = $('<tr>\n' +
                                '            <th>软件'+index+'</th>\n' +
                                '            <td>'+this+'</td>\n' +
                                '          </tr>');
                            // 将数据追加到 tbody中
                            $("#data-body").append(tr);
                            index++;

                        });
                    }
                }
            })
        })


    </script>
</html>